home *** CD-ROM | disk | FTP | other *** search
- // =================================================================================
- // CActiveXApp.cpp ⌐1996-1997 Microsoft Corporation. All rights reserved.
- // portions ⌐1995 Metrowerks Inc. All rights reserved.
- // =================================================================================
-
- #include <LGrowZone.h>
- #include <LMenu.h>
- #include <LMenuBar.h>
- #include <LMouseTracker.h>
- #include <LString.h>
- #include <LWindow.h>
- #include <LTableView.h>
- #include <LHierarchyTable.h>
- #include <LGAColorSwatch.h>
- #include <LGASeparator.h>
- #include <PP_Messages.h>
- #include <PPobClasses.h>
- #include <UDesktop.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <UReanimator.h>
- #include <URegistrar.h>
- #include <UTextTraits.h>
-
- // ÑActiveXÑ - begin ActiveX headers
- #include "ActiveXAPI.h"
-
- #include "ActiveXAppConstants.h"
- #include "CActiveXInfo.h"
- #include "CActiveXTable.h"
- #include "CActiveXColorPane.h"
- #include "CActiveXDocument.h"
- #include "CActiveXView.h"
- #include "CActiveXAppView.h"
- #include "CActiveXShadowView.h"
- //#include "CActiveXPeriodical.h"
- #include "CActiveXApp.h"
- #include "CActiveXAppAttachment.h"
- // ÑActiveXÑ - end ActiveX headers
-
-
- // =================================================================================
- // Ñ Main Program
- // =================================================================================
-
- void
- main( void )
- {
- // Initialize the heap. Parameter is number
- // of master handle blocks to allocate.
- InitializeHeap( 4 );
-
- // Initialize the MacOS toolbox.
- UQDGlobals::InitializeToolbox( &qd );
-
- // Install a GrowZone function to catch low memory situations.
- // Parameter is the size of the memory reserve in bytes.
- new LGrowZone( 20000 );
-
- // Create the application object and run it.
- CActiveXApp theApp;
-
- theApp.Run();
- }
-
-
- // ---------------------------------------------------------------------------------
- // Ñ CActiveXApp::CActiveXApp
- // ---------------------------------------------------------------------------------
- // Constructor
-
- CActiveXApp::CActiveXApp()
- {
- // Setup the throw and signal actions.
- SetDebugThrow_( debugAction_Alert );
- SetDebugSignal_( debugAction_Alert );
-
- // Register PowerPlant class creator functions.
- RegisterAllPPClasses();
-
- // ÑActiveXÑ Register custom classes for the ActiveX pane types
- URegistrar::RegisterClass( CActiveXAppView::class_ID, (ClassCreatorFunc) CActiveXAppView::CreateActiveXAppViewStream );
- URegistrar::RegisterClass( CActiveXShadowView::class_ID, (ClassCreatorFunc) CActiveXShadowView::CreateActiveXShadowViewStream );
-
- // ************** ObjectDesc Table classes registration ************** //
-
- RegisterClass_(LGASeparator);
-
- // Register custom classes.
- URegistrar::RegisterClass( CActiveXInfo::class_ID,
- (ClassCreatorFunc) CActiveXInfo::CreateActiveXInfoStream );
- URegistrar::RegisterClass( CActiveXColorPane::class_ID, (ClassCreatorFunc) CActiveXColorPane::CreateColorPaneStream );
- URegistrar::RegisterClass( CActiveXTable::class_ID,
- (ClassCreatorFunc) CActiveXTable::CreateActiveXTableStream );
-
- // ************** End ObjectDesc Table classes registration ************** //
-
- AddAttachment( new CActiveXAppAttachment() );
- }
-
-
- // ---------------------------------------------------------------------------------
- // Ñ CActiveXApp::~CActiveXApp
- // ---------------------------------------------------------------------------------
- // Destructor
-
- CActiveXApp::~CActiveXApp()
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // Ñ Initialize
- // ---------------------------------------------------------------------------
- // Last chance to initialize Application before processing events
-
- void CActiveXApp::Initialize()
- {
- // Start the mouse tracker
- LMouseTracker *mouseTracker = new LMouseTracker;
- mouseTracker->StartIdling();
- }
-
-
- // ---------------------------------------------------------------------------------
- // Ñ CActiveXApp::StartUp
- // ---------------------------------------------------------------------------------
-
- void
- CActiveXApp::StartUp()
- {
- // ÑActiveXÑ on startup bring up the default document type
- ObeyCommand( cmd_DefaultDocument, nil );
- }
-
-
- // ---------------------------------------------------------------------------
- // Ñ CActiveXApp::ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- CActiveXApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- case cmd_NewSinglePane:
- SendAECreateDocument();
- break;
- case cmd_NewMultiPane:
- case cmd_NewMultiContext:
- new CActiveXDocument( this, nil, inCommand );
- break;
-
- default:
- cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------------
- // Ñ CActiveXApp::FindCommandStatus
- // ---------------------------------------------------------------------------------
- // set menu command status
-
- void
- CActiveXApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName )
- {
- switch ( inCommand ) {
-
- case cmd_NewSinglePane:
- case cmd_NewMultiPane:
- case cmd_NewMultiContext:
- {
- outEnabled = true;
- break;
- }
-
- case cmd_PageSetup:
- {
- // Short circuit the page setup command
- // since this example doesn't print.
- outEnabled = false;
- }
- break;
-
- default:
- {
- // Call inherited.
- LDocApplication::FindCommandStatus( inCommand,
- outEnabled, outUsesMark, outMark, outName );
- }
- break;
-
- }
- }
-
-
- // ---------------------------------------------------------------------------------
- // Ñ CActiveXApp::OpenDocument
- // ---------------------------------------------------------------------------------
- // open a document from an FSSpec
-
- void
- CActiveXApp::OpenDocument(
- FSSpec *inMacFSSpec )
- {
- // ÑActiveXÑ create a new document using the file spec
- new CActiveXDocument( this, inMacFSSpec, 0 );
- }
-
-
- // ---------------------------------------------------------------------------------
- // Ñ CActiveXApp::MakeNewDocument
- // ---------------------------------------------------------------------------------
- // make a new empty document
-
- LModelObject *
- CActiveXApp::MakeNewDocument()
- {
- // ÑActiveXÑ Make a new empty document of the default type
- return new CActiveXDocument( this, nil, cmd_DefaultDocument );
- }
-
-
- // ---------------------------------------------------------------------------------
- // Ñ CActiveXApp::ChooseDocument
- // ---------------------------------------------------------------------------------
- // choose a document with standard file
-
- void
- CActiveXApp::ChooseDocument()
- {
- // Deactivate the desktop.
- ::UDesktop::Deactivate();
-
- // Browse for a document.
- SFTypeList theTypeList = {'Actx'};
- StandardFileReply theReply;
- ::StandardGetFile( nil, 1, theTypeList, &theReply );
-
- // Activate the desktop.
- ::UDesktop::Activate();
-
- // Send an apple event to open the file.
- if ( theReply.sfGood ) SendAEOpenDoc( theReply.sfFile );
- }
-
-
-